<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"><title>centos 搭建本地yum源、网络yum源 | FFing</title><meta name="author" content="FFing"><meta name="copyright" content="FFing"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="频繁访问外网源占用带宽，且速度有限，所以搭建局域网源是必须的。 yum源下载rpm，是由本地repo文件配置控制的，所有核心就是我们的repo文件。 repo文件格式： 12345678#中括号内为yum源标签[ffing]#yum源描述name&#x3D;ffing-centos7#yum源地址（baseurl支持四种协议：ftp、http、file、rsync）baseurl&#x3D;http:&#x2F;&#x2F;ffing.">
<meta property="og:type" content="article">
<meta property="og:title" content="centos 搭建本地yum源、网络yum源">
<meta property="og:url" content="https://blog.ffing.fun/posts/20211221153232-4c7d71f9.html">
<meta property="og:site_name" content="FFing">
<meta property="og:description" content="频繁访问外网源占用带宽，且速度有限，所以搭建局域网源是必须的。 yum源下载rpm，是由本地repo文件配置控制的，所有核心就是我们的repo文件。 repo文件格式： 12345678#中括号内为yum源标签[ffing]#yum源描述name&#x3D;ffing-centos7#yum源地址（baseurl支持四种协议：ftp、http、file、rsync）baseurl&#x3D;http:&#x2F;&#x2F;ffing.">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2021-12-21T07:32:32.000Z">
<meta property="article:modified_time" content="2023-01-25T10:48:56.000Z">
<meta property="article:author" content="FFing">
<meta property="article:tag" content="yum优先级">
<meta property="article:tag" content="yum源">
<meta property="article:tag" content="本地yum">
<meta property="article:tag" content="网络yum">
<meta name="twitter:card" content="summary"><link rel="shortcut icon" href="https://src.ffing.cn/hexo/img/fn_logo_32x32.png"><link rel="canonical" href="https://blog.ffing.fun/posts/20211221153232-4c7d71f9"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://lf6-cdn-tos.bytecdntp.com/cdn/expire-1-M/font-awesome/6.0.0/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://cdn.staticfile.org/fancyapps-ui/4.0.31/fancybox.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"/search.xml","preload":false,"languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":200},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    justifiedGallery: {
      js: 'https://cdnjs.cloudflare.com/ajax/libs/flickr-justified-gallery/2.1.2/fjGallery.min.js',
      css: 'https://cdnjs.cloudflare.com/ajax/libs/flickr-justified-gallery/2.1.2/fjGallery.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isAnchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'centos 搭建本地yum源、网络yum源',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2023-01-25 18:48:56'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const detectApple = () => {
      if(/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/gundongtiao.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/custom.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/auth_icon.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/home_file_list.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/full_page.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/universe.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/nav_menu.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/txmap.css"><link rel="stylesheet" href="//at.alicdn.com/t/c/font_3830672_5bphzb91mjp.css" media="defer" onload="this.media='all'"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/foot.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/aside.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/other_page.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/loading_bar.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/loading_gif.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/copyright.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/right_down_button.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/mouse.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/page_bg.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/lightlight.css"><link rel="stylesheet" href="https://src.ffing.cn/hexo/css/51la.css"><script charset="UTF-8" id="LA_COLLECT" src="//sdk.51.la/js-sdk-pro.min.js"></script><script src="https://sdk.51.la/perf/js-sdk-perf.min.js" crossorigin="anonymous"></script><script> LA.init({id:"JwsAbeTPm16yxMNJ",ck:"JwsAbeTPm16yxMNJ"})</script><script>new LingQue.Monitor().init({id:"JwsAbeTPm16yxMNJ",sendSuspicious:true});</script><!-- hexo injector head_end start --><link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/Zfour/Butterfly-double-row-display@1.00/cardlistpost.min.css"/>
<style>#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags:before {content:"\A";
  white-space: pre;}#recent-posts > .recent-post-item >.recent-post-info > .article-meta-wrap > .tags > .article-meta__separator{display:none}</style>
<!-- hexo injector head_end end --><meta name="generator" content="Hexo 6.3.0"></head><body><div id="loading-box" onclick="document.getElementById(&quot;loading-box&quot;).classList.add(&quot;loaded&quot;)"><div class="loading-bg"><div class="loading-img"></div><div class="loading-image-dot"></div></div></div><script>const preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',()=> { preloader.endLoading() })

if (false) {
  document.addEventListener('pjax:send', () => { preloader.initLoading() })
  document.addEventListener('pjax:complete', () => { preloader.endLoading() })
}</script><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/blue/pace-theme-minimal.min.css"/><script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js"></script><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="sidebar-site-data site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">10</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">23</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">2</div></a></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/archives/"><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/timeline/"><span> 更新</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="not-top-img" id="page-header"><nav id="nav"><span id="blog_name"><div class="back-home-button" tabindex="-1"><i class="back-home-button-icon fas fa-grip-vertical"></i><div class="back-menu-list-groups"><div class="back-menu-list-group"><div class="back-menu-list-title">网页</div><div class="back-menu-list"><a class="back-menu-item" href="https://www.ffing.cn" title="前往首页" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://src.ffing.cn/hexo/img/fn_white_logo.png"/><span class="back-menu-item-text">首页</span></a><a class="back-menu-item" href="http://pan.ffing.cn/" rel="external nofollow" title="前往alist网盘" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://src.ffing.cn/hexo/img/alist_logo.png"/><span class="back-menu-item-text">alist网盘</span></a><a class="back-menu-item" href="https://kms.ffing.cn/" rel="external nofollow" title="前往kms服务" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://src.ffing.cn/hexo/img/kms_logo.png"/><span class="back-menu-item-text">kms服务</span></a></div></div><div class="back-menu-list-group"><div class="back-menu-list-title">在线工具</div><div class="back-menu-list"><a class="back-menu-item" href="https://www.iconfont.cn" rel="noopener nofollow" title="前往阿里icon" target="_blank" one-link-mark="yes"><img class="back-menu-item-icon" src="https://src.ffing.cn/hexo/img/ali-icon_logo.png"/><span class="back-menu-item-text">阿里icon</span></a></div></div></div></div><a id="site-name" href="/"><div class="title">FFing</div><i class="fa-solid fa-house"></i></a></span><div class="mask-name-container"><center id="name-container"><a id="page-name" href="javascript:btf.scrollToDest(0, 500)">PAGE_NAME</a></center></div><div id="weather"></div><div id="tp-weather-widget"></div> <div id="menus"><div class="nav-button" id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="nav-button" id="darkmode_navswitch"><a class="darkmode_switchbutton" type="button" title="浅色和深色模式转换" onclick="switchDarkMode()"><i class="fas fa-adjust"></i></a></div><div class="nav-button" id="nav-totop"><a class="totopbtn"><i class="fas fa-arrow-up"></i><span id="percent" onclick="btf.scrollToDest(0,500)">0</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/archives/"><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><span> 关于</span></a></div><div class="menus_item"><a class="site-page" href="/timeline/"><span> 更新</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav></header><main class="layout" id="content-inner"><div id="post"><div id="post-info"><h1 class="post-title">centos 搭建本地yum源、网络yum源</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-12-21T07:32:32.000Z" title="发表于 2021-12-21 15:32:32">2021-12-21</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2023-01-25T10:48:56.000Z" title="更新于 2023-01-25 18:48:56">2023-01-25</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/Linux/">Linux</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">893</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>3分钟</span></span></div></div></div><article class="post-content" id="article-container"><p>频繁访问外网源占用带宽，且速度有限，所以搭建局域网源是必须的。</p>
<p>yum源下载rpm，是由本地repo文件配置控制的，所有核心就是我们的repo文件。</p>
<p>repo文件格式：</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">#中括号内为yum源标签</span><br><span class="line">[ffing]</span><br><span class="line">#yum源描述</span><br><span class="line">name=ffing-centos7</span><br><span class="line">#yum源地址（baseurl支持四种协议：ftp、http、file、rsync）</span><br><span class="line">baseurl=http://ffing.cn/yum</span><br><span class="line">#秘钥检测：</span><br><span class="line">gpgcheck=0</span><br></pre></td></tr></table></figure>

<p>环境：</p>
<ul>
<li>系统版本：centos7.6</li>
<li>ISO镜像：centos7.6（yum源文件）</li>
<li>nginx1.16（web服务器）</li>
</ul>
<p>流程</p>
<ul>
<li>搭建本地yum源</li>
<li>发布yum目录</li>
<li>网络yum源配置</li>
<li>yum源优先级</li>
</ul>
<h2 id="一，搭建本地yum源"><a href="#一，搭建本地yum源" class="headerlink" title="一，搭建本地yum源"></a>一，搭建本地yum源</h2><p>简单讲：创建yum仓库目录–&gt;配置repo文件–&gt;测试OK</p>
<h4 id="1-准备本地yum仓库"><a href="#1-准备本地yum仓库" class="headerlink" title="1.准备本地yum仓库"></a>1.准备本地yum仓库</h4><p>将iso文件复制到本地目录，作为仓库源</p>
<p>1.1提前创建需要目录</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#创建本地yum仓库目录</span><br><span class="line">mkdir -p /yum/centos7-iso</span><br></pre></td></tr></table></figure>

<p>1.2挂载iso镜像到&#x2F;mnt</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line">#挂载光盘到mnt下</span><br><span class="line">mount /dev/sr0 /mnt</span><br></pre></td></tr></table></figure>

<p>1.3拷贝光盘内容到我们上面创建的yum仓库目录</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">cp -r /mnt/* /yum/centos7-iso</span><br></pre></td></tr></table></figure>

<h4 id="2-配置repo文件"><a href="#2-配置repo文件" class="headerlink" title="2.配置repo文件"></a>2.配置repo文件</h4><p>2.1清除本地所有repo</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">#创建备份目录</span><br><span class="line">mkdir /etc/yum.repos.d/bak</span><br><span class="line">#移动所有repo文件到bak目录下，保证/etc/yum.repos.d/下为空目录</span><br><span class="line">mv /etc/yum.repos.d/* /etc/yum.repos.d/bak</span><br></pre></td></tr></table></figure>

<p>2.2创建本地repo</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">#创建本地local.repo</span><br><span class="line">vi /etc/yum.repos.d/local.repo</span><br><span class="line"></span><br><span class="line">#####内容如下#####</span><br><span class="line">[local-centos7]</span><br><span class="line">name=local-CentOS7-iso</span><br><span class="line">baseurl=file:///yum/centos7-iso/</span><br><span class="line">gpgcheck=0</span><br></pre></td></tr></table></figure>

<h4 id="3-测试"><a href="#3-测试" class="headerlink" title="3.测试"></a>3.测试</h4><p>本地测试，以安装tree为例</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y install tree</span><br></pre></td></tr></table></figure>

<p>下图安装提示标签源为local-centos7，与上面我们配置的一致。</p>
<p><img src="https://qnimg.ffing.cn/wp-content/uploads/2021/12/image-24.png"></p>
<p>至此，本地yum源就搭建完成了！</p>
<h2 id="二，web发布yum源目录"><a href="#二，web发布yum源目录" class="headerlink" title="二，web发布yum源目录"></a>二，web发布yum源目录</h2><p>yum仓库目录做web服务（为网络源做基础）</p>
<p>从上面的搭建过程，可以看出yum源的访问路径，就是repo中的baseurl配置的地址，所以，我们做网络源就需要将我们本地的yum仓库目录发布出去。</p>
<p>安装nginx，并开放80端口，关闭selinux</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line">#安装nginx</span><br><span class="line">yum -y install nginx</span><br><span class="line">#防火墙放行80端口</span><br><span class="line">firewall-cmd --add-port=80/tcp --zone=public --permanent</span><br><span class="line">firewall-cmd --reload</span><br><span class="line">#临时关闭selinux</span><br><span class="line">setenforce 0</span><br><span class="line">#永久关闭selinux</span><br><span class="line">sed -i &#x27;s/enforcing/disable/&#x27; /etc/selinux/config</span><br></pre></td></tr></table></figure>

<p>修改nginx配置，增加location规则，定义yum源</p>
<p>vi &#x2F;etc&#x2F;nginx&#x2F;nginx.conf</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line">#插入location规则</span><br><span class="line">location /yum &#123;</span><br><span class="line">alias /yum/centos7-iso;</span><br><span class="line">autoindex on;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

<p><img src="https://qnimg.ffing.cn/wp-content/uploads/2021/12/image-25.png"></p>
<p>重启nginx</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">systemctl restart nginx</span><br></pre></td></tr></table></figure>

<p>访问http:&#x2F;&#x2F;服务器IP或域名&#x2F;yum</p>
<p>我的vm服务器地址ip为192.168.68.175</p>
<p><img src="https://qnimg.ffing.cn/wp-content/uploads/2021/12/image-26.png"></p>
<h2 id="三，网络yum源配置"><a href="#三，网络yum源配置" class="headerlink" title="三，网络yum源配置"></a>三，网络yum源配置</h2><p>寻找网络中，其他的机器配置repo文件，yum源地址为我们发布的yum地址即可!</p>
<p>这里我以vm-2机器为例！</p>
<p>同样的操作，移除原有repo文件，仅创建lan.repo做测试。</p>
<p>vi &#x2F;etc&#x2F;yum.repos.d&#x2F;lan.repo</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">#源标签我定义为网络源的ip地址（你自己想定义上面都可以，方便自己辨识）</span><br><span class="line">#baseurl为上面那台机器192.168.68.175发布的地址！</span><br><span class="line">[192.168.68.175]</span><br><span class="line">name=192.168.68.175-yum</span><br><span class="line">baseurl=http://192.168.68.175/yum</span><br><span class="line">gpgcheck=0</span><br></pre></td></tr></table></figure>

<p>vm-2 安装tree，yum源标签显示的是我们上面创建的192.168.68.175地址。</p>
<p><img src="https://qnimg.ffing.cn/wp-content/uploads/2021/12/image-27.png"></p>
<h2 id="四，yum源优先级（yum-plugin-priorities-noarch）"><a href="#四，yum源优先级（yum-plugin-priorities-noarch）" class="headerlink" title="四，yum源优先级（yum-plugin-priorities.noarch）"></a>四，yum源优先级（yum-plugin-priorities.noarch）</h2><p>有本地源和网络源的时，就有优先级问题。</p>
<p>安装yum-plugin-priorities.noarch模块</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">yum -y insatll yum-plugin-priorities.noarch</span><br></pre></td></tr></table></figure>

<p>安装完成后，修改repo文件配置priority参数定义优先级，值越小，优先级越高！</p>
<p>如下：（默认没有配置priority参数的优先级最低）</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">#本地repo文件，加入priority参数！！！</span><br><span class="line">[local-centos7]</span><br><span class="line">name=local-CentOS7-iso</span><br><span class="line">baseurl=file:///yum/centos7-iso/</span><br><span class="line">gpgcheck=0</span><br><span class="line">priority=1</span><br></pre></td></tr></table></figure></article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="https://blog.ffing.fun">FFing</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://blog.ffing.fun/posts/20211221153232-4c7d71f9.html">https://blog.ffing.fun/posts/20211221153232-4c7d71f9.html</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://blog.ffing.fun" target="_blank">FFing</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/yum%E4%BC%98%E5%85%88%E7%BA%A7/">yum优先级</a><a class="post-meta__tags" href="/tags/yum%E6%BA%90/">yum源</a><a class="post-meta__tags" href="/tags/%E6%9C%AC%E5%9C%B0yum/">本地yum</a><a class="post-meta__tags" href="/tags/%E7%BD%91%E7%BB%9Cyum/">网络yum</a></div><div class="post_share"><div class="social-share" data-image="" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://lib.baomitu.com/social-share.js/1.0.16/css/share.min.css" media="print" onload="this.media='all'"><script src="https://lib.baomitu.com/social-share.js/1.0.16/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="next-post pull-full"><a href="/posts/20211118115517-65c613e1.html"><img class="next-cover" src="" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">centos 部署多个tomcat并systemd控制</div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%80%EF%BC%8C%E6%90%AD%E5%BB%BA%E6%9C%AC%E5%9C%B0yum%E6%BA%90"><span class="toc-number">1.</span> <span class="toc-text">一，搭建本地yum源</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#1-%E5%87%86%E5%A4%87%E6%9C%AC%E5%9C%B0yum%E4%BB%93%E5%BA%93"><span class="toc-number">1.0.1.</span> <span class="toc-text">1.准备本地yum仓库</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#2-%E9%85%8D%E7%BD%AErepo%E6%96%87%E4%BB%B6"><span class="toc-number">1.0.2.</span> <span class="toc-text">2.配置repo文件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#3-%E6%B5%8B%E8%AF%95"><span class="toc-number">1.0.3.</span> <span class="toc-text">3.测试</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BA%8C%EF%BC%8Cweb%E5%8F%91%E5%B8%83yum%E6%BA%90%E7%9B%AE%E5%BD%95"><span class="toc-number">2.</span> <span class="toc-text">二，web发布yum源目录</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%B8%89%EF%BC%8C%E7%BD%91%E7%BB%9Cyum%E6%BA%90%E9%85%8D%E7%BD%AE"><span class="toc-number">3.</span> <span class="toc-text">三，网络yum源配置</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%9B%9B%EF%BC%8Cyum%E6%BA%90%E4%BC%98%E5%85%88%E7%BA%A7%EF%BC%88yum-plugin-priorities-noarch%EF%BC%89"><span class="toc-number">4.</span> <span class="toc-text">四，yum源优先级（yum-plugin-priorities.noarch）</span></a></li></ol></div></div></div></div></main><footer id="footer"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By FFing</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div><div id="footer-banner"><div class="footer-banner-links"><div class="footer-banner-left"><div class="footer-banner-left"><div id="footer-banner-tips"></div><script src="https://src.ffing.cn/hexo/js/typed.min.foot_daziji.js"></script><script>var typed = new Typed("#footer-banner-tips", {
  strings: ["你不在正经事上忧虑,就会在乱七八糟事上忧虑,能力守恒!", "折腾硬件、软件;折腾系统、平台;折腾开发、环境;折腾window、linux;折腾,折腾,瞎J8折腾."],
  startDelay: 200,
  backDelay: 2000,
  typeSpeed: 100,
  loop: true,
  backSpeed: 20
})
</script></div></div><div class="footer-banner-right"><p><a target="_blank" href="https://hexo.io/"><img src="http://src.ffing.cn/hexo/img/Frame-Hexo-blue.svg" title="框架"></a>&nbsp;<a target="_blank" href="https://butterfly.js.org/"><img src="http://src.ffing.cn/hexo/img/Theme-Butterfly.svg" title="主题"></a>&nbsp;<a target="_blank" href="https://www.upyun.com/"><img src="http://src.ffing.cn/hexo/img/CDN又拍云.svg" title="CDN加速"></a>&nbsp;<a target="_blank" href="https://www.51.la/"><img src="http://src.ffing.cn/hexo/img/Analytics-51la.svg" title="51la统计"></a>&nbsp;<a target="_blank" href="https://www.upyun.com/"><img src="http://src.ffing.cn/hexo/img/豫ICP备2021016009.svg" title="ICP备案"></a></p></div></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><span id="loading-status"></span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="is-center" id="loading-database"><i class="fas fa-spinner fa-pulse"></i><span>  数据库加载中</span></div><div class="search-wrap"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div><hr/><div id="local-search-results"></div></div></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.staticfile.org/fancyapps-ui/4.0.31/fancybox.umd.min.js"></script><script src="/js/search/local-search.js"></script><div class="js-pjax"></div><script src="https://src.ffing.cn/hexo/js/jquery.min.3.6.3.js"></script><canvas id="universe"></canvas><script defer src="https://src.ffing.cn/hexo/js/universe.js"></script><script defer src="https://src.ffing.cn/hexo/js/switchDarkMode.js"></script><script defer src="https://src.ffing.cn/hexo/js/nav_menu.js"></script><script async data-pjax src="https://src.ffing.cn/hexo/js/txmap.js"></script><script async src="//at.alicdn.com/t/c/font_3830672_5bphzb91mjp.js"></script><script src="https://src.ffing.cn/hexo/js/jquery.min.js"></script><script src="https://src.ffing.cn/hexo/js/weather.js"></script><script src="https://src.ffing.cn/hexo/js/foot_runtime.js"></script></div></body></html>